package nc.ui.qc.c011.ace.handler;

import javax.swing.Action;
import nc.ui.pubapp.uif2app.event.IAppEventHandler;
import nc.ui.pubapp.uif2app.event.card.CardBodyTabChangedEvent;
import nc.ui.pubapp.uif2app.model.BillManageModel;
import nc.ui.uif2.UIState;

public class CardBodyTabChangedHandler implements IAppEventHandler<CardBodyTabChangedEvent>{
	
	private BillManageModel model;

	@Override
	public void handleAppEvent(CardBodyTabChangedEvent e) {
		String tableCode = e.getBillCardPanel().getCurrentBodyTableCode();
		Action[] toolBarActions = e.getBillCardPanel().getBodyTabbedPane().getToolBarActions();
		if(null == toolBarActions || toolBarActions.length == 0)
			return;
		boolean enabled = "pk_applybill_b".equals(tableCode);
		
		if(UIState.EDIT != getModel().getUiState() && UIState.ADD != getModel().getUiState()) {
			enabled = false;
		}
		
		for(Action action:toolBarActions) {
			action.setEnabled(enabled);
		}
	}

	public BillManageModel getModel() {
		return model;
	}

	public void setModel(BillManageModel model) {
		this.model = model;
	}
	
	

}
